﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace MVCWeb.Models
{
    public class CartInfo
    {
        public int NumItemsInCart = 0;
        public double TotalPriceOfUnplacedOrders = 0.00;
        public List<OrderModel> list = null;

        public CartInfo()
        {
        }

        public int UpdateCartInfo(List<OrderModel> list)
        {
            foreach (OrderModel order in list)
            {
                if (order.is_ordered == 0)
                {
                    List<OrderItemModel> itemsInOrderList = OrderItemClientService.GetOrderProducts(order.order_id);
                    foreach (OrderItemModel orderitem in itemsInOrderList)
                    {
                        NumItemsInCart += orderitem.quantity;
                        TotalPriceOfUnplacedOrders += orderitem.sub_total;
                    }
                }
            }
            return NumItemsInCart;
        }
    }
}